package csvloader;
import java.sql.Connection;

import org.apache.tomcat.jdbc.pool.DataSource;
import org.apache.tomcat.jdbc.pool.PoolProperties;

public class SimplePOJOExample {

	public static void main(String[] args) throws Exception {
		PoolProperties p = new PoolProperties();
		p.setUrl("jdbc:oracle:thin:@dev-isle:1521:orcl");
		p.setDriverClassName("oracle.jdbc.driver.OracleDriver");
		p.setUsername("cust_jtb_12m");
		p.setPassword("cust_jtb_12m");
		p.setJmxEnabled(true);
		p.setTestWhileIdle(false);
		p.setTestOnBorrow(true);
		p.setValidationQuery("SELECT 1");
		p.setTestOnReturn(false);
		p.setValidationInterval(30000);
		p.setTimeBetweenEvictionRunsMillis(30000);
		p.setMaxActive(100);
		p.setInitialSize(10);
		p.setMaxWait(10000);
		p.setRemoveAbandonedTimeout(60);
		p.setMinEvictableIdleTimeMillis(30000);
		p.setMinIdle(10);
		p.setLogAbandoned(true);
		p.setRemoveAbandoned(true);
		p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"
						+ "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
		DataSource datasource = new DataSource();
		datasource.setPoolProperties(p);

		Connection con = null;
//		try {
//			con = datasource.getConnection();
//			Statement st = con.createStatement();
//			ResultSet rs = st.executeQuery("select * from employee");
//			int cnt = 1;
//			while (rs.next()) {
//				System.out.println((cnt++) + ". employee_code:" + rs.getString("employee_code")
//						+ " employee_name:" + rs.getString("employee_name"));
//			}
//			rs.close();
//			st.close();
//		} finally {
//			if (con != null)
//				try {
//					con.close();
//				} catch (Exception ignore) {
//				}
//		}
//		try {
//			con = datasource.getConnection();
//			DefinitionTable table = new DefinitionTable();
//			DefinitionBean[] recs = (DefinitionBean[])table.selectAll(con);
//			for (int i = 0; i < recs.length; i++){
//				System.out.println("getIdem_Code_:"+ recs[i].getIdem_name_());
//			}
//		} catch (Exception e){
//			e.printStackTrace();
//		} finally {
//			if (con != null)
//				try {
//					con.close();
//				} catch (Exception ignore) {
//				}
//		}

	}

}
